package user.mapper;

import com.spring4all.spring.boot.starter.hbase.api.RowMapper;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import user.contstant.Constants;
import user.vo.FeedBack;

/**
 * FeedBack HBase Row to Object
 * 用户反馈数据与java用户反馈对象映射
 */
public class FeedBackRowMapper implements RowMapper<FeedBack> {

    /** 定义字节数组*/
    //列族i信息
    private static byte[] FAMILY_I = Constants.FeedbackTable.FAMILY_I.getBytes();
    private static byte[] USER_ID = Constants.FeedbackTable.USER_ID.getBytes();
    private static byte[] TYPE = Constants.FeedbackTable.TYPE.getBytes();
    private static byte[] TEMPLATE_ID = Constants.FeedbackTable.TEMPLATE_ID.getBytes();
    private static byte[] COMMENT = Constants.FeedbackTable.COMMENT.getBytes();

    @Override
    public FeedBack mapRow(Result result, int i) throws Exception {

        FeedBack feedBack = new FeedBack();
        feedBack.setUserId(Bytes.toLong(result.getValue(FAMILY_I,USER_ID)));
        feedBack.setType(Bytes.toString(result.getValue(FAMILY_I,TYPE)));
        feedBack.setTemplateId(Bytes.toString(result.getValue(FAMILY_I,TEMPLATE_ID)));
        feedBack.setComment(Bytes.toString(result.getValue(FAMILY_I,COMMENT)));
        return feedBack;
    }
}
